{% extends 'base.html' %}
{% block content %}

<title>{{ title }} - 注册</title>
<h2>注册</h2>
<form method="POST">
    <div class="form-group">
        <label for="username">用户名</label>
        <input type="text" class="form-control" id="username" name="username" required>
    </div>
    <div class="form-group">
        <label for="password">密码</label>
        <input type="password" class="form-control" id="password" name="password" required>
    </div>
    
    <div class="form-group">
        <div class="h-captcha" data-sitekey="c05cb716-85bc-4580-ad5c-9d0c046e4642"></div>
    </div>
    
    <button type="submit" class="btn btn-primary">注册</button>
</form>

<script src="https://js.hcaptcha.com/1/api.js" async defer></script>

<script>
document.addEventListener('DOMContentLoaded', function() {
    // 表单提交时验证 hCaptcha
    document.getElementById('loginForm').addEventListener('submit', function(e) {
        // 检查 hCaptcha 是否已完成
        if (hcaptcha.getResponse() === "") {
            e.preventDefault();
            alert('请完成验证码验证');
            // 可选: 重置验证码以让用户重新尝试
            hcaptcha.reset();
        }
    });
});
</script>

{% endblock %}
